package com.zuihai.app.mvp.ui.utils;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;

import static com.blankj.utilcode.util.Utils.getContext;

/**
 * Created by Administrator on 2017/5/9 0009.
 */

public class RecyclerNoDivisionHelper {

    //垂直布局
    public static void initLinearLayoutBind(RecyclerView recyclerView, BaseQuickAdapter adapter, BaseQuickAdapter.OnItemClickListener listener){
        //添加布局管理器
        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);

        //添加条目点击事件
        adapter.setOnItemClickListener(listener);
        recyclerView.setAdapter(adapter);
    }
    //
    public static void initGridLayoutBind(RecyclerView recyclerView, int gridNumber,BaseQuickAdapter adapter, BaseQuickAdapter.OnItemClickListener listener){

        //添加布局管理器,并设置显示几列
        GridLayoutManager layoutManager = new GridLayoutManager(getContext(),gridNumber);
        recyclerView.setLayoutManager(layoutManager);
        //添加条目点击事件
        adapter.setOnItemClickListener(listener);
        recyclerView.setAdapter(adapter);
    }
}
